package com.wl.es7.study.test.client.java;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.ResourceBundle;

public class JdbcUtils {

    private static String url = null;

    private static String userName;

    private static String password;
    static {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");

            ResourceBundle resourceBundle = ResourceBundle.getBundle("jdbc");
            url = resourceBundle.getString("jdbc.url");
            userName = resourceBundle.getString("jdbc.username");
            password = resourceBundle.getString("jdbc.password");
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    public static Connection createConnect(){
        try {
            Connection connection = DriverManager.getConnection(url, userName, password);
            return connection;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }




}
